package org.rcy.framework.thrift.metadata;

import org.apache.thrift.protocol.TType;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

public class MapMetaData extends FieldValueMetaData {

	private static final long serialVersionUID = 1L;

	public final FieldValueMetaData keyMetaData;
	public final FieldValueMetaData valueMetaData;

	public MapMetaData(Type javaType, Type[] typeArguments) {
		super(TType.MAP, javaType);
		//TODO 判断Map泛型和类中的泛型参数是否一致
		// if (javaType instanceof ParameterizedType) {
		typeArguments = ((ParameterizedType) javaType).getActualTypeArguments();
		// if (typeArguments.length == 2) {
		this.keyMetaData = MetaDataBuilder.valueMetaData(typeArguments[0],null);
		this.valueMetaData = MetaDataBuilder.valueMetaData(typeArguments[1],null);
	}
}
